
// 商品列表
var goodsListModule = goodsListModule();
// 商品详情
var goodsDetails = goodsDetails();
// 支付
var payModule = pay();

// index首页
var indexModule = indexModule();
// 商城
var mallModule = mallModule();

var routes = [
    { path: '/', component: indexModule },
    { path: '/mall', component: mallModule }
];

var router = new VueRouter({
    routes
});



new Vue({
    el: '#app',
    router,
    created: function(){
        ajax({
            url: './php/index-ifuser.php',
            data: {
                user: 'user'
            },
            method: 'post',
            success: function(res){
                res = res && JSON.parse(res);
                if(res.error == 1){
                    //console.log(res)
                    sessionStorage.setItem('user', JSON.stringify(res.data));
                }else if(res.error == 0){
                    elasticFrame('您尚未登录,是否前往登录?', function(){
                        window.location.href = './login.html';
                    });
                }
            }
        });
    }
});

